
doc = """

 Colors from www.ColorBrewer.org by Cynthia A. Brewer, Geography, Pennsylvania State University.


 These colour schemes are licensed under the conditions of the Apache Software License:

 Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes

 Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.

 Licensed under the Apache License, Version 2.0 (the "License"); 
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software distributed
 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 CONDITIONS OF ANY KIND, either express or implied. See the License for the
 specific language governing permissions and limitations under the License.

"""

def palette(name,n):
    if not palettes.has_key(name):
        raise ValueError,"No such palette: "+str(name)
    p=palettes[name]
    limits=p['limits']
    offset=limits[0]
    if n > limits[1]:
        raise ValueError,"palette max colours is "+str(limits[1])
    if n < limits[0]:
        raise ValueError,"palette has minimum of "+str(limits[0])+" colours"
    return p['colours'][n-offset]

def iconName(name):
    return ":/icons/icons/"+str(name).lower()+".png"

palettes = {
'Set1': {'limits':(3,9),
        'colours': [
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
  [255,255,51],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
  [255,255,51],
  [166,86,40],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
  [255,255,51],
  [166,86,40],
  [247,129,191],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
  [255,255,51],
  [166,86,40],
  [247,129,191],
  [153,153,153],
],
[
  [228,26,28],
  [55,126,184],
  [77,175,74],
  [152,78,163],
  [255,127,0],
  [255,255,51],
  [166,86,40],
  [247,129,191],
  [153,153,153],
],
]
        }

,
'Set2': {'limits':(3,8),
        'colours': [

[
  [102,194,165],
  [252,141,98],
  [141,160,203],
],
[
  [102,194,165],
  [252,141,98],
  [141,160,203],
  [231,138,195],
],
[
  [102,194,165],
  [252,141,98],
  [141,160,203],
  [231,138,195],
  [166,216,84],
],
[
  [102,194,165],
  [252,141,98],
  [141,160,203],
  [231,138,195],
  [166,216,84],
  [255,217,47],
],
[
  [102,194,165],
  [252,141,98],
  [141,160,203],
  [231,138,195],
  [166,216,84],
  [255,217,47],
  [229,196,148],
],
[
  [102,194,165],
  [252,141,98],
  [141,160,203],
  [231,138,195],
  [166,216,84],
  [255,217,47],
  [229,196,148],
  [179,179,179],
],

]

},

"Set3": {'limits':(3,12),
        'colours': [
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
  [252,205,229],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
  [252,205,229],
  [217,217,217],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
  [252,205,229],
  [217,217,217],
  [188,128,189],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
  [252,205,229],
  [217,217,217],
  [188,128,189],
  [204,235,197],
],
[
  [141,211,199],
  [255,255,179],
  [190,186,218],
  [251,128,114],
  [128,177,211],
  [253,180,98],
  [179,222,105],
  [252,205,229],
  [217,217,217],
  [188,128,189],
  [204,235,197],
  [255,237,111],
],
]
},

"Dark2": {'limits':(3,8),
        'colours': [
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
],
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
  [231,41,138],
],
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
  [231,41,138],
  [102,166,30],
],
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
  [231,41,138],
  [102,166,30],
  [230,171,2],
],
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
  [231,41,138],
  [102,166,30],
  [230,171,2],
  [166,118,29],
],
[
  [27,158,119],
  [217,95,2],
  [117,112,179],
  [231,41,138],
  [102,166,30],
  [230,171,2],
  [166,118,29],
  [102,102,102],
],
]
},

"Pastel1": {'limits':(3,9),
        'colours': [

[
  [251,180,174],
  [179,205,227],
  [204,235,197],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
  [254,217,166],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
  [254,217,166],
  [255,255,204],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
  [254,217,166],
  [255,255,204],
  [229,216,189],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
  [254,217,166],
  [255,255,204],
  [229,216,189],
  [253,218,236],
],
[
  [251,180,174],
  [179,205,227],
  [204,235,197],
  [222,203,228],
  [254,217,166],
  [255,255,204],
  [229,216,189],
  [253,218,236],
  [242,242,242],
]

]
},

"Pastel2": {'limits':(3,8),
        'colours': [
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
],
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
  [244,202,228],
],
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
  [244,202,228],
  [230,245,201],
],
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
  [244,202,228],
  [230,245,201],
  [255,242,174],
],
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
  [244,202,228],
  [230,245,201],
  [255,242,174],
  [241,226,204],
],
[
  [179,226,205],
  [253,205,172],
  [203,213,232],
  [244,202,228],
  [230,245,201],
  [255,242,174],
  [241,226,204],
  [204,204,204],
],
]
},

"Accent": {'limits':(3,8),
        'colours': [

[
  [127,201,127],
  [190,174,212],
  [253,192,134],
],
[
  [127,201,127],
  [190,174,212],
  [253,192,134],
  [255,255,153],
],
[
  [127,201,127],
  [190,174,212],
  [253,192,134],
  [255,255,153],
  [56,108,176],
],
[
  [127,201,127],
  [190,174,212],
  [253,192,134],
  [255,255,153],
  [56,108,176],
  [240,2,127],
],
[
  [127,201,127],
  [190,174,212],
  [253,192,134],
  [255,255,153],
  [56,108,176],
  [240,2,127],
  [191,91,23],
],
[
  [127,201,127],
  [190,174,212],
  [253,192,134],
  [255,255,153],
  [56,108,176],
  [240,2,127],
  [191,91,23],
  [102,102,102],
],
]
},

"Paired": {'limits':(3,12),
        'colours': [
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
  [255,127,0],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
  [255,127,0],
  [202,178,214],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
  [255,127,0],
  [202,178,214],
  [106,61,154],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
  [255,127,0],
  [202,178,214],
  [106,61,154],
  [255,255,153],
],
[
  [166,206,227],
  [31,120,180],
  [178,223,138],
  [51,160,44],
  [251,154,153],
  [227,26,28],
  [253,191,111],
  [255,127,0],
  [202,178,214],
  [106,61,154],
  [255,255,153],
  [177,89,40],
],
]
}
}

import sys
if __name__=="__main__":
    for name,pal in palettes.iteritems():
        sys.stdout.write(name+": ")
        for i in range(pal['limits'][0],pal['limits'][1]):
            sys.stdout.write(str(i)+"...")
            p = palette(name,i)
        sys.stdout.write("\n")

            
